﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///OrderDetail 的摘要说明
/// </summary>
public class OrderDetail
{
	public OrderDetail()
	{
        OnSubmiting += delegate { };
        OnSubmited += delegate { };
	}

    public string ProductID { get; set; }
    public string ProductName { get; set; }
    public string ProductURL { get; set; }
    public float SinglePrice { get; set; }
    public int BuyCount { get; set; }
    public float Discount { get; set; }
    public float SinglePriceAfterDiscount { get; set; }
    public float AllPriceAfaterDiscount { get; set; }
    public int NeedJifen { get; set; }
    public int AddJifen { get; set; }
    public float TotalPrice { get; set; }
    public int TotalNeedJifen { get; set; }
    public int TotalAddJifen { get; set; }
    public string ProductType { get; set; }
    public DateTime InputDate { get; set; }
    public string OrderID { get; set; }
    public string Memo { get; set; }

    public delegate void OrderDetailSubmitingEventHandler(OrderDetail sender, OrderDetailSubmitEventArgs args);
    public event OrderDetailSubmitingEventHandler OnSubmiting;

    public delegate void OrderDetailSubmitedEventHandler(OrderDetail sender, string OrderDetailPkValueInDB);
    public event OrderDetailSubmitedEventHandler OnSubmited;

    public void SubmitToDB(string OrderListPK)
    {
        this.OrderID = OrderListPK;
        OrderDetailSubmitEventArgs args = new OrderDetailSubmitEventArgs();
        args.OrderDetail = this;
        OnSubmiting(this, args);
        if (args.Canel) { return; }

        OnSubmited(this, args.OrderDetailPKValueInDB);
    }
}
